<template>
	<view class="container">
		<view class="list-cell b-b m-t" @click="navTo('/pagesA/perInfo/perInfo')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">个人资料</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell b-b" @click="navTo('/pages/user/address/address')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">收货地址</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		
		<!-- <view class="list-cell m-t">
			<text class="cell-tit">消息推送</text>
			<switch checked color="#fa436a" @change="switchChange" />
		</view> -->
		<view class="list-cell m-t b-b" @click="navTo('清除缓存')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">清除缓存</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell b-b" @click="navTo('/pagesA/set/about/about')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">关于Hypref Mall</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell" @click="checkVersion">
			<text class="cell-tit">检查更新</text>
			<text class="cell-tip">当前版本 {{$api._api.ApiVersionText}}</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<!-- <view class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">退出登录</text>
		</view> -->
	</view>
</template>

<script>
	import {  
	    mapMutations  , mapState
	} from 'vuex';
	export default {
		data() {
			return {
				
			};
		},
		computed: {
			...mapState(['hasLogin','userInfo'])
		},
		methods:{
			...mapMutations(['logout']),
			navTo(url){
				uni.navigateTo({  
					url
				})  
			}, 
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录么',
				    success: (e)=>{
				    	if(e.confirm){
				    		this.logout();
				    		setTimeout(()=>{
				    			uni.navigateBack();
				    		}, 200)
				    	}
				    }
				});
			},
			//switch
			switchChange(e){
				let statusTip = e.detail.value ? '打开': '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},
			checkVersion:function(e){
				let _param = {
					//version_code:this.$api._api.ApiVersionCode,
					token:this.userInfo.token
				};
				let that = this;
				this.$api.postUrl(this.$api._api.ApiVersion,_param,function(res){
					let _data = {};
					if(typeof(res.data) == "object"){
						_data = res.data;
					}else{
						_data = JSON.parse(res.data);
					}
					
					if(_data.status == 0){
						if(_data.data.code > that.$api._api.ApiVersionCode){
							uni.showModal({ //提醒用户更新  
								title: "更新提示",
								content: _data.data.msg,  
								success: (res) => {
									if (res.confirm) {
										plus.runtime.openURL(_data.data.url);
									}
								}
							})
						}else{
							that.$api.msg("已是最新版本");
						}
					}else{
						that.$api.msg(_data.message);
					}
				})
			}
		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20rpx $page-row-spacing;
		line-height:60rpx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40rpx;
			.cell-tit{
				color: $uni-color-primary;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30rpx;
		}
		&.m-t{
			margin-top: 16rpx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10rpx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2rpx;
			color: $font-color-dark;
			margin-right:10rpx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16rpx) scale(.84);
		}
	}
</style>
